import 'package:flutter/cupertino.dart';
import 'package:imember/UI/Home.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Util/PageUtil.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyImage.dart';
import 'package:imember/Widget/MyPage.dart';

class GZ_HistoryRecord extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _GZ_HistoryRecord();
  }
}

class _GZ_HistoryRecord extends State {
  @override
  Widget build(BuildContext context) {
    return MyPage(
        true
            ? Container(
                child: Column(
                  children: [
                    Row(children: [
                      Expanded(flex: 1, child: Container(height: 58)),
                      Expanded(
                          flex: 1,
                          child:
                              Center(child: Text("操作時間", style: TextStyle(fontSize: 20, color: MyColor.C70, fontWeight: FontWeight.bold)))),
                      Expanded(
                          flex: 1,
                          child:
                              Center(child: Text("營業額", style: TextStyle(fontSize: 20, color: MyColor.C70, fontWeight: FontWeight.bold)))),
                      Expanded(
                          flex: 1,
                          child:
                              Center(child: Text("短溢金額", style: TextStyle(fontSize: 20, color: MyColor.C70, fontWeight: FontWeight.bold)))),
                      Expanded(
                          flex: 1,
                          child:
                              Center(child: Text("留存金額", style: TextStyle(fontSize: 20, color: MyColor.C70, fontWeight: FontWeight.bold)))),
                      Expanded(
                          flex: 1,
                          child:
                              Center(child: Text("匯出金額", style: TextStyle(fontSize: 20, color: MyColor.C70, fontWeight: FontWeight.bold)))),
                      Container(width: 64),
                    ]),
                    Container(height: 2, color: MyColor.DD),
                    Expanded(
                        child: ListView.separated(
                            padding: EdgeInsets.all(0),
                            itemBuilder: (BuildContext context, int index) {
                              return Item(
                                controlTime: "2020/01/11 20:58",
                                businessAmount: "\$33000",
                                lackAmount: "\$33000",
                                remainingAmount: "\$33000",
                                expendAmount: "\$33000",
                              );
                            },
                            separatorBuilder: (BuildContext context, int index) {
                              return Container(height: 2, color: MyColor.DD);
                            },
                            itemCount: 4)),
                    Container(
                        margin: EdgeInsets.fromLTRB(0, 0, 45, 35),
                        child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [
                          IconBtn("儲存並列印", "ic_printer.png", width: 170),
                          Container(width: 13),
                          IconBtn("儲存", "ic_check.png", width: 120, bgColor: MyColor.Orange, onTap: () {
                            PageUtil().openRemoveAll(context, Home());
                          }),
                        ]))
                  ],
                ),
              )
            : Center(child: Text("目前尚無紀錄", style: TextStyle(fontSize: 30, color: MyColor.C70, fontWeight: FontWeight.bold))),
        title: "歷史紀錄",
        showNotice: true);
  }
}

class Item extends StatelessWidget {
  String controlTime;
  String businessAmount;
  String lackAmount;
  String remainingAmount;
  String expendAmount;

  Item(
      {required this.controlTime,
      required this.businessAmount,
      required this.lackAmount,
      required this.remainingAmount,
      required this.expendAmount});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      child: Row(children: [
        Expanded(
            flex: 1,
            child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
              LocalImage("ic_add_g.png", width: 20, height: 20),
              Text("關帳", style: TextStyle(fontSize: 20, color: MyColor.Black, fontWeight: FontWeight.bold)),
            ])),
        Expanded(
            flex: 1,
            child: Container(
                alignment: Alignment.center,
                padding: EdgeInsets.fromLTRB(0, 8, 0, 8),
                child: Text(controlTime,
                    textAlign: TextAlign.center, style: TextStyle(fontSize: 20, color: MyColor.Black, fontWeight: FontWeight.bold)))),
        Expanded(
            flex: 1,
            child: Center(child: Text(businessAmount, style: TextStyle(fontSize: 20, color: MyColor.Black, fontWeight: FontWeight.bold)))),
        Expanded(
            flex: 1,
            child: Center(child: Text(lackAmount, style: TextStyle(fontSize: 20, color: MyColor.Black, fontWeight: FontWeight.bold)))),
        Expanded(
            flex: 1,
            child: Center(child: Text(remainingAmount, style: TextStyle(fontSize: 20, color: MyColor.Black, fontWeight: FontWeight.bold)))),
        Expanded(
            flex: 1,
            child: Center(child: Text(expendAmount, style: TextStyle(fontSize: 20, color: MyColor.Black, fontWeight: FontWeight.bold)))),
        LocalImage("ic_arrow_r.png", width: 48, height: 48),
        Container(width: 16),
      ]),
    );
  }
}
